<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      class Animal {
        constructor(name, age) {
          this.name = name;
          this.age = age;
        }
        run() {
          alert(this.name + "runrunrun");
        }
      }
      //es6的面向对象用class定义类，每个类都有一个构造函数叫做constructor,用来放属性
      //   方法放在constructor外面

      let xiaohuang = new Animal("小熊熊", 18);
      xiaohuang.run();
      alert(xiaohuang.name);

      class Cat extends Animal {
        constructor(name, age, miao) {
          super(name, age);
          this.miao = miao;
        }
        say() {
          alert(this.name + "miaomiaomiao");
        }
      }
      let xiaohua = new Cat("小花", 2, "mimi");
      xiaohua.run(); //使用继承的父类的方法
      alert(xiaohua.name);

      //   其实父类 叫做超类,因为是用super继承的
    </script>
  </body>
</html>
